import {
    FETCH_LAYOUT_DATA,
    FETCH_RENDER_REPLY_POST_DATA,
    FETCH_RENDER_POST_DETAIL_DATA,
    FETCH_RENDER_NEW_POST_DATA,
    FETCH_HOME_DATA
} from "../action-types";
import fetch from 'isomorphic-fetch';
const {SERVER_ADDRESS} = process.env;
export const fetchLayoutData = () => {
    return dispatch => {
        return fetch(`${SERVER_ADDRESS}/user/info`)
            .then(res => res.json())
            .then(json => dispatch({type: FETCH_LAYOUT_DATA, payload: json}))
    }
};
export const fetchNewPostPage = () => {
    return dispatch => {
        return fetch(`${SERVER_ADDRESS}/user/info`)
            .then(res => res.json())
            .then(json => dispatch({type: FETCH_RENDER_NEW_POST_DATA, payload: json}))
    }
};
export const fetchPostDetailPage = () => {
    return dispatch => {
        return fetch(`${SERVER_ADDRESS}/user/info`)
            .then(res => res.json())
            .then(json => dispatch({type: FETCH_RENDER_POST_DETAIL_DATA, payload: json}))
    }
};
export const fetchReplyPostPage = () => {
    return dispatch => {
        return fetch(`${SERVER_ADDRESS}/user/info`)
            .then(res => res.json())
            .then(json => dispatch({type: FETCH_RENDER_REPLY_POST_DATA, payload: json}))
    }
};
export const fetchHomePage = () => {
    return dispatch => {
        return fetch(`${SERVER_ADDRESS}/user/info`)
            .then(res => res.json())
            .then(json => dispatch({type: FETCH_HOME_DATA, payload: json}))
    }
};
